package com.gdust.hzx.user.controller;

import com.gdust.hzx.model.entity.user.UserAddress;
import com.gdust.hzx.model.vo.common.Result;
import com.gdust.hzx.model.vo.common.ResultCodeEnum;
import com.gdust.hzx.user.service.UserAddressService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * ClassName: UserAddressController
 * Package: com.gdust.hzx.user.controller
 * Description:
 * <p>
 * 流程：
 * 入口：购物车点击去结算按钮 ，进入结算页面(订单确认页面)
 * 1、 用户地址信息列表，结算页选中默认地址
 * 2、 购物车中选择的商品列表，及商品的总金额
 *
 * @Author syun
 * @Create 2024/12/27 19:34
 * @Version 1.0
 */
@Tag(name = "用户地址接口")
@RestController
@RequestMapping(value = "/api/user/userAddress")
public class UserAddressController {
    @Autowired
    private UserAddressService userAddressService;

    /**
     * 获取用户地址
     * @return
     */
    @Operation(summary = "获取用户地址列表")
    @GetMapping("auth/findUserAddressList")
    public Result findUserAddressList() {
        //自定义方法：获取用户地址
        List<UserAddress> list = userAddressService.findUserAddressList();
        return Result.build(list, ResultCodeEnum.SUCCESS);
    }

    //根据id获取收货地址信息
    @Operation(summary = "获取收货地址信息")
    @GetMapping("getUserAddress/{id}")
    public UserAddress getUserAddress(@PathVariable Long id) {
        //获取地址信息
        return userAddressService.getUserAddress(id);
    }


}
